class AddFeededAtToOrders < ActiveRecord::Migration
  def self.up
    add_column :orders, :feeded_at, :datetime
    if not Rails.env.test?      
      Enterprise.all.each do |enterprise|
        Thread.current[:current_user_id] = enterprise.admin_id
        enterprise.orders.each do |order|
          order.reset_feeded_at!
        end
      end
    end
  end

  def self.down
    remove_column :orders,:feeded_at
  end
end